//
//  PaySucceedVC.swift
//  RPay
//
//  Created by CharlieLiao on 2017/7/8.
//  Copyright © 2017年 Charlie. All rights reserved.
//

import UIKit

class PaySucceedVC: BaseVC {
    
    // MARK: - Init
    convenience init() {
        self.init(nibName: "PaySucceedView", bundle: nil)
    }
    
    // MARK: - Life Cycle
    override func viewDidLoad() {
        super.viewDidLoad()
        title = LocalStr("支付成功")
        // Do any additional setup after loading the view.
        
        if isBuy {
            查看订单.isHidden = false
            查看订单.layer.cornerRadius = 19
            查看订单.layer.borderWidth = 0.5
            查看订单.layer.borderColor = UIColor.appTheme.cgColor
            返回首页.isHidden = false
            返回首页.layer.cornerRadius = 19
            返回首页.layer.borderWidth = 0.5
            返回首页.layer.borderColor = UIColor.appTheme.cgColor
        }
        
        priceLabel.text = price
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        var viewControllers = navigationController!.viewControllers
        if isBuy { // 购买商品模式
            
        } else {
            if viewControllers.count > 3 {
                viewControllers.removeSubrange(2..<viewControllers.count-1)
                navigationController!.viewControllers = viewControllers
            }
        }
    }
    
    // MARK: - Event respond
    @IBAction func tap查看订单() {
        navigationController!.popToRootViewController(animated: false)
        IFShared().tabbarVC!.selectedIndex = 2
        
        let nav = IFShared().tabbarVC!.selectedViewController as! UINavigationController
        let vc = MyOrderVC()
        vc.hidesBottomBarWhenPushed = true
        nav.pushViewController(vc, animated: false)
    }
    
    @IBAction func tap返回首页() {
        navigationController!.popToRootViewController(animated: false)
        IFShared().tabbarVC!.selectedIndex = 0
    }
    
    // MARK: - Get / Set
    
    var isBuy = false
    var price: String!
    
    @IBOutlet var priceLabel: UILabel!
    @IBOutlet var 查看订单: UIButton!
    @IBOutlet var 返回首页: UIButton!
    
}
